<%--
  Created by IntelliJ IDEA.
  User: MGL
  Date: 2020/11/5
  Time: 9:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>部门树</title>
    <link rel="stylesheet" type="text/css" href="css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="css/H-ui.admin.css" />
    <link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="lib/jquery/jquery-3.5.1.js"></script>
    <script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript" src="js/jquerySession.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
    <SCRIPT LANGUAGE="JavaScript">
        var zTreeObj;
        // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
        var setting = {
            async: {
                enable: true, //打开异步
                url: "http://localhost:8080/ssmdemo_war_exploded/getDept/getDeptListByParentId",
                autoParam: ["id","name"]
            },
            callback: {
                onClick: zTreeOnClick
            }
        };
        // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
        var zNodes = [];
        $(document).ready(function(){
            zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });

        function zTreeOnClick(event, treeId, treeNode) {
            // alert(treeNode.tId + ", " + treeNode.name);
            $("#deptZtreeName").val(treeNode.name)
            $("#deptZtreeId").val(treeNode.id)
        };

        function selectDept(){
            var deptName=$("#deptZtreeName").val()
            var deptId=$("#deptZtreeId").val()

            if(!$("#deptZtreeName").val()){
                alert("请选择部门")
                return;
            }else {
                $.session.set("deptId",deptId)
                $.session.set("deptName",deptName)

                layer_close()
            }


        }
    </SCRIPT>
</head>
<body>
<div class="formControls col-xs-8 col-sm-9">
    <input id="deptZtreeName" type="text" style="width: 120px" class="input-text" name="deptZtreeName">
    <input id="deptZtreeId" type="hidden" >
    <input type="button" class="btn btn-primary radius" value="确定部门" onclick="selectDept()">
    <ul id="treeDemo" class="ztree"></ul>
</div>
</body>
</html>
